package com.woniuxy.carlife.carlifeuserweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifeuserweb.entity.Carbrand;
import com.woniuxy.carlife.carlifeuserweb.mapper.CarbrandMapper;
import com.woniuxy.carlife.carlifeuserweb.service.CarbrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CarbrandServiceImpl
 * @Description:
 * @date 2021/4/6 20:02
 **/

@Service
public class CarbrandServiceImpl extends ServiceImpl<CarbrandMapper, Carbrand> implements CarbrandService {

    @Resource
    CarbrandMapper carbrandMapper;

    /*
     * 功能描述〈查询汽车品牌〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 17:05
     * @throws
     */

    @Override
    public List<Carbrand> findCarbrand()  {
        QueryWrapper<Carbrand> carbrandQueryWrapper = new QueryWrapper<>();
        List<Carbrand> carbrands = carbrandMapper.selectList(carbrandQueryWrapper);

        return carbrands != null ? carbrands : null;
    }

    /*
     * 功能描述〈根据汽车品牌id查询〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 17:30
     * @throws
     */

    @Override
    public Carbrand findCarbrandBycarbrandId(String carbrandId)  {
        QueryWrapper<Carbrand> carbrandQueryWrapper = new QueryWrapper<>();
        QueryWrapper<Carbrand> carbrand_id = carbrandQueryWrapper.eq("carbrand_id", carbrandId);
        Carbrand carbrand = carbrandMapper.selectOne(carbrand_id);
        return carbrand == null ? null : carbrand;
    }
}
